const ap = new APlayer({
    container: document.getElementById('aplayer'),
    order: 'random',
    preload: 'auto',
    listMaxHeight: '336px',
    volume: 0.5,
    mutex: true,
    lrcType: 3,
    /* 下方更改为你自己的歌单就行 */
    audio: [
        {
            name: "海阔天空",
            artist: "Beyond",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E6%B5%B7%E9%98%94%E5%A4%A9%E7%A9%BA%20-%20Beyond.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E6%B5%B7%E9%98%94%E5%A4%A9%E7%A9%BA%20-%20Beyond.lrc",
            theme: "#171513"
        },
        {
            name: "光辉岁月",
            artist: "Beyond",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E5%85%89%E8%BE%89%E5%B2%81%E6%9C%88%20-%20Beyond.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E5%85%89%E8%BE%89%E5%B2%81%E6%9C%88%20-%20Beyond.lrc",
            theme: "#171513"
        },
        {
            name: "岁月神偷",
            artist: "金玟岐",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E5%B2%81%E6%9C%88%E7%A5%9E%E5%81%B7%20-%20%E9%87%91%E7%8E%9F%E5%B2%90.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E5%B2%81%E6%9C%88%E7%A5%9E%E5%81%B7%20-%20%E9%87%91%E7%8E%9F%E5%B2%90.lrc",
            theme: "#171513"
        },
        {
            name: "一路向北",
            artist: "周杰伦",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E4%B8%80%E8%B7%AF%E5%90%91%E5%8C%97%20-%20%E5%91%A8%E6%9D%B0%E4%BC%A6.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E4%B8%80%E8%B7%AF%E5%90%91%E5%8C%97%20-%20%E5%91%A8%E6%9D%B0%E4%BC%A6.lrc",
            theme: "#171513"
        },
        {
            name: "稻香",
            artist: "周杰伦",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E7%A8%BB%E9%A6%99%20-%20%E5%91%A8%E6%9D%B0%E4%BC%A6.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E7%A8%BB%E9%A6%99%20-%20%E5%91%A8%E6%9D%B0%E4%BC%A6.lrc",
            theme: "#171513"
        },
        {
            name: "晴天",
            artist: "周杰伦",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E6%99%B4%E5%A4%A9%20-%20%E5%91%A8%E6%9D%B0%E4%BC%A6.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E6%99%B4%E5%A4%A9%20-%20%E5%91%A8%E6%9D%B0%E4%BC%A6.lrc",
            theme: "#171513"
        },
        {
            name: "青花瓷",
            artist: "周杰伦",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E9%9D%92%E8%8A%B1%E7%93%B7%20-%20%E5%91%A8%E6%9D%B0%E4%BC%A6.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E9%9D%92%E8%8A%B1%E7%93%B7%20-%20%E5%91%A8%E6%9D%B0%E4%BC%A6.lrc",
            theme: "#171513"
        },
        {
            name: "所念皆星河",
            artist: "房东的猫",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E6%89%80%E5%BF%B5%E7%9A%86%E6%98%9F%E6%B2%B3%20-%20%E6%88%BF%E4%B8%9C%E7%9A%84%E7%8C%AB.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E6%89%80%E5%BF%B5%E7%9A%86%E6%98%9F%E6%B2%B3%20-%20%E6%88%BF%E4%B8%9C%E7%9A%84%E7%8C%AB.lrc",
            theme: "#171513"
        },
        {
            name: "云烟成雨",
            artist: "房东的猫",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E4%BA%91%E7%83%9F%E6%88%90%E9%9B%A8%20-%20%E6%88%BF%E4%B8%9C%E7%9A%84%E7%8C%AB.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E4%BA%91%E7%83%9F%E6%88%90%E9%9B%A8%20-%20%E6%88%BF%E4%B8%9C%E7%9A%84%E7%8C%AB.lrc",
            theme: "#171513"
        },
        {
            name: "斑马斑马",
            artist: "房东的猫",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E6%96%91%E9%A9%AC%E6%96%91%E9%A9%AC%20-%20%E6%88%BF%E4%B8%9C%E7%9A%84%E7%8C%AB.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E6%96%91%E9%A9%AC%E6%96%91%E9%A9%AC%20-%20%E6%88%BF%E4%B8%9C%E7%9A%84%E7%8C%AB.lrc",
            theme: "#171513"
        },
        {
            name: "像我这样的人",
            artist: "毛不易",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E5%83%8F%E6%88%91%E8%BF%99%E6%A0%B7%E7%9A%84%E4%BA%BA%20-%20%E6%AF%9B%E4%B8%8D%E6%98%93.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E5%83%8F%E6%88%91%E8%BF%99%E6%A0%B7%E7%9A%84%E4%BA%BA%20-%20%E6%AF%9B%E4%B8%8D%E6%98%93.lrc",
            theme: "#171513"
        },
        {
            name: "消愁",
            artist: "毛不易",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E6%B6%88%E6%84%81%20-%20%E6%AF%9B%E4%B8%8D%E6%98%93.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E6%B6%88%E6%84%81%20-%20%E6%AF%9B%E4%B8%8D%E6%98%93.lrc",
            theme: "#171513"
        },
        {
            name: "那些年",
            artist: "胡夏",
            url: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/%E9%82%A3%E4%BA%9B%E5%B9%B4%20-%20%E8%83%A1%E5%A4%8F.mp3",
            cover: "https://img.zengjunyin.com/default/202201242031856.jpg",
            lrc: "https://pan.zengjunyin.com/d/%E9%9F%B3%E4%B9%90/lrc/%E9%82%A3%E4%BA%9B%E5%B9%B4%20-%20%E8%83%A1%E5%A4%8F.lrc",
            theme: "#171513"
        },
    ]
});

/* 底栏歌词 */
setInterval(function () {
    $("#lrc").html("<span class='lrc-show'><i class='iconfont icon-music'></i> " + $(".aplayer-lrc-current").text() + " <i class='iconfont icon-music'></i></span>");
}, 500);

/* 音乐通知及控制 */
ap.on('play', function () {
    music = $(".aplayer-title").text() + $(".aplayer-author").text();
    iziToast.info({
        timeout: 3000,
        iconUrl: './img/play.png',
        displayMode: 'replace',
        title: '音乐通知',
        message: '正在播放：' + '&nbsp;' + music
    });
    $("#play").html("<i class='iconfont icon-pause'>");
    $("#music-name").html($(".aplayer-title").text() + $(".aplayer-author").text());
    if ($(document).width() >= 990) {
        $('.power').css("cssText", "display:none");
        $('#lrc').css("cssText", "display:block !important");
    }
});

ap.on('pause', function () {
    $("#play").html("<i class='iconfont icon-play'>");
    if ($(document).width() >= 990) {
        $('#lrc').css("cssText", "display:none !important");
        $('.power').css("cssText", "display:block");
    }
});

//音量调节
$(document).ready(function () {
    $('#volume').val(0.5);
})

function changevolume() {
    var x = $("#volume").val();
    ap.volume(x, true);
    if (x == 0) {
        $("#volume-ico").html("<i class='iconfont icon-volume-x'></i>");
    } else if (x > 0 && x <= 0.3) {
        $("#volume-ico").html("<i class='iconfont icon-volume'></i>");
    } else if (x > 0.3 && x <= 0.6) {
        $("#volume-ico").html("<i class='iconfont icon-volume-1'></i>");
    } else {
        $("#volume-ico").html("<i class='iconfont icon-volume-2'></i>");
    }
}

$("#music").hover(function () {
    $('.music-text').css("display", "none");
    $('.music-volume').css("display", "flex");
}, function () {
    $('.music-text').css("display", "block");
    $('.music-volume').css("display", "none");
})

/* 一言与音乐切换 */
$('#open-music').on('click', function () {
    $('#hitokoto').css("display", "none");
    $('#music').css("display", "flex");
});

$("#hitokoto").hover(function () {
    $('#open-music').css("display", "flex");
}, function () {
    $('#open-music').css("display", "none");
})

$('#music-close').on('click', function () {
    $('#music').css("display", "none");
    $('#hitokoto').css("display", "flex");
});

/* 上下曲 */
$('#play').on('click', function () {
    ap.toggle();
    $("#music-name").html($(".aplayer-title").text() + $(".aplayer-author").text());
});

$('#last').on('click', function () {
    ap.skipBack();
    $("#music-name").html($(".aplayer-title").text() + $(".aplayer-author").text());
});

$('#next').on('click', function () {
    ap.skipForward();
    $("#music-name").html($(".aplayer-title").text() + $(".aplayer-author").text());
});

/* 打开音乐列表 */
$('#music-open').on('click', function () {
    if ($(document).width() >= 990) {
        $('#box').css("display", "block");
        $('#row').css("display", "none");
        $('#more').css("cssText", "display:none !important");
    }
});